package com.lxh.command;

import java.util.ArrayList;
import java.util.List;

/**
 * Invoker类 要求命令执行这个请求
 * Create by lxh on 2020/2/14
 */
public class Waiter {

    private List<Command> commands = new ArrayList<>();

    public void setOrder(Command command) {
        commands.add(command);
        System.out.println("增加订单" + command.toString());
    }

    public void cancelOrder(Command command) {
        commands.remove(command);
        System.out.println("取消订单" + command.toString());
    }

    public void action() {
        for (Command command : commands) {
            command.executeCommand();
        }
    }
}
